package com.youlu.campus.admin.kuaidi;

import com.youlu.campus.common.base.QResult;
import com.youlu.campus.service.notify.KuaiDi100Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 快递信息
 *
 * @Description: KuaiDi100Controller
 * @Date 2025/9/15
 * @module KuaiDi100Controller
 * @author: su
 */
@RestController
@RequestMapping(value = "/kuaidi100")
public class KuaiDi100Controller {

    @Autowired
    private KuaiDi100Service kuaiDi100Service;

    /**
     * 拉取 最近 15天的 物流信息
     *
     * @return
     */
    @RequestMapping(value = "/pull-all")
    public QResult pullTrackTask() {
        return QResult.success( kuaiDi100Service.pullTrackTask());
    }

    /**
     * 根据单号重新订阅
     *
     * @param number
     * @return
     */
    @GetMapping("/repull-number")
    public QResult rePull(@RequestParam String number) {
        String[] logisticsNoArr = number.split(",");
        kuaiDi100Service.pullTrack(Arrays.asList(logisticsNoArr));
        return QResult.success();
    }

    /**
     * 根据单号重新订阅
     *
     * @param number
     * @return
     */
    @GetMapping("/public/kuaidi100/resub")
    public QResult reSub(@RequestParam String number) {
        String[] logisticsNoArr = number.split(",");
        return kuaiDi100Service.reSub(logisticsNoArr);
    }
}
